package com.libraryManage.controller;

import com.libraryManage.commons.utils.ResponseEntity;
import com.libraryManage.service.DictionaryService;
import com.libraryManage.vo.DicBookSortVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @CreateDate 2021-01-31
 * @Author yufang
 */
@Api(tags={"字典管理接口"})
@RestController
@CrossOrigin
@RequestMapping("/manage/dictionary")
public class DictionaryController {

    @Autowired
    private DictionaryService dictionaryService;

    @ApiOperation("查询所有图书类别")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/bookSortList" , method = RequestMethod.POST)
    public ResponseEntity<List<DicBookSortVo>> getDicBookSortList(@RequestBody DicBookSortVo vo){

        return dictionaryService.getDicBookSortList(vo);

    }

    @ApiOperation("更新图书类别")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/updateBookSort" , method = RequestMethod.POST)
    public ResponseEntity<List<DicBookSortVo>> updateDicBookSort(@RequestBody DicBookSortVo vo){

        return dictionaryService.updateDicBookSort(vo);

    }

    @ApiOperation("删除图书类别")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/deleteBookSort" , method = RequestMethod.GET)
    public ResponseEntity<List<DicBookSortVo>> deleteDicBookSort(int id){

        return dictionaryService.deleteDicBookSort(id);

    }

    @ApiOperation("新增图书类别")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/createDicBookSort" , method = RequestMethod.POST)
    public ResponseEntity<List<DicBookSortVo>> createDicBookSort(@RequestBody DicBookSortVo vo){

        return dictionaryService.createDicBookSort(vo);

    }

}
